#include "MultiCamControl.h"

MultiCamControl::MultiCamControl()
{
	

}

MultiCamControl::~MultiCamControl()
{


}

void MultiCamControl::ResizeCallbackAll(int w, int h)
{
	for( int i = 0; i < cameras.size(); i++ ) {
		cameras[i].ResizeCallbackHandler(w,h);
	}
}

void MultiCamControl::ResizeCallbackOne(int w, int h, int idx)
{
	cameras[idx].ResizeCallbackHandler(w,h);
}

void MultiCamControl::ModelView(int idx) {
	cameras[idx].ModelView();
}

void MultiCamControl::ResetAll()
{
	for( int i = 0; i < cameras.size(); i++ ) {
		cameras[i].ResetPosition();
	}

}

void MultiCamControl::GetViewSize( int idx, int* wout, int* hout )
{
	this->cameras[idx].GetWH(wout, hout);
}

void MultiCamControl::InitCamsUniform(int w, int h)
{
	numFrameDrawn = -1; // nothing has yet been rendered!

	//for cam one, the overhead camera
	cameras[0].SetWindowID(1);
	cameras[0].Initialize( 0,100, -2, 0.0, 0, 0.0, 1.0, 200.0 );
	cameras[0].SetViewSize(2*w,3*h);

	// *IF* we want multiple views, then:
	// place the cameras uniformly distributed about y-axis
	// pointing at the origin
	// slightly up in y coordinate
	int numcam = cameras.size()-1;
	float step = 2*M_PI / numcam;
	float Tup = 10.0;
	float dist = 60.0;
	float xpos, zpos;
	for( int i = 1; i <= numcam; i++ ) {
		//float ang = i * step + step / numcam;
		float ang = (i == 1) * M_PI + M_PI/2;
		xpos = dist * cos( ang );
		zpos = dist * sin( ang );
		cameras[i].SetWindowID(i+1);
		cameras[i].Initialize( xpos, Tup, zpos, 0.0, 0.0, 0.0, 1.0, 300.0 );
		cameras[i].SetViewSize(2*w,3*h);
		
	}
		
	
}